/*
 * ov5640.h
 *
 *  Created on: May 24, 2021
 *      Author: kirk_
 */

#ifndef OV5640_H_
#define OV5640_H_

#include "main.h"

//#define OV5640_PWDN  	PGout(9)			//POWER DOWN控制信号,由PCF8574_P2控制
#define OV5640_RST(n)  	(n?HAL_GPIO_WritePin(DCMI_RST_GPIO_Port,DCMI_RST_Pin,GPIO_PIN_SET):HAL_GPIO_WritePin(DCMI_RST_GPIO_Port,DCMI_RST_Pin,GPIO_PIN_RESET))//复位控制信号
//////////////////////////////////////////////////////////////////////////////////
#define OV5640_ID               0X5640  	//OV5640的芯片ID


#define OV5640_ADDR        		0X78		//OV5640的IIC地址

//OV5640相关寄存器定义
#define OV5640_CHIPIDH          0X300A  	//OV5640芯片ID高字节
#define OV5640_CHIPIDL          0X300B  	//OV5640芯片ID低字节



uint8_t OV5640_WR_Reg(uint16_t reg,uint8_t data);
uint8_t OV5640_RD_Reg(uint16_t reg);
void OV5640_PWDN_Set(uint8_t sta);
uint8_t OV5640_Init(void);
void OV5640_JPEG_Mode(void);
void OV5640_RGB565_Mode(void);
void OV5640_Light_Mode(uint8_t mode);
void OV5640_Color_Saturation(uint8_t sat);
void OV5640_Brightness(uint8_t bright);
void OV5640_Contrast(uint8_t contrast);
void OV5640_Sharpness(uint8_t sharp);
void OV5640_Special_Effects(uint8_t eft);
void OV5640_Test_Pattern(uint8_t mode);
void OV5640_Flash_Ctrl(uint8_t sw);
uint8_t OV5640_OutSize_Set(uint16_t offx,uint16_t offy,uint16_t width,uint16_t height);
uint8_t OV5640_ImageWin_Set(uint16_t offx,uint16_t offy,uint16_t width,uint16_t height);
uint8_t OV5640_Focus_Init(void);
uint8_t OV5640_Focus_Single(void);
uint8_t OV5640_Focus_Constant(void);

extern const uint16_t OV5640_jpeg_reg_tbl[40][2];
extern const uint16_t ov5640_rgb565_reg_tbl[44][2];
extern const uint16_t ov5640_uxga_init_reg_tbl[206][2];
extern const unsigned char OV5640_AF_Config[0xfed];

#endif /* OV5640_H_ */
